#!/usr/bin/python

import os

def main():
    
    visit_int = "      java.lang.Object visit (Visitor visitor);\n"
    visit_impl = "      protected final java.lang.Object[] nodes;\n"
    
    code_int = "      public void setType( int type ); public int getType();\n"
    code_impl = "      private int type; public void setType( int type ) { this.type = type; } public int getType() { return type; }\n" 

    kitsch = open( 'Kitsch.java' )
    newKitsch = open( 'temp', 'w' );
    for line in kitsch:
        newKitsch.write( line )
        if line == visit_int:
            newKitsch.write( code_int )
        if line == visit_impl:
            newKitsch.write( code_impl )
    kitsch.close()
    newKitsch.close()
    os.rename( 'temp', 'Kitsch.java' )

if __name__ == '__main__':
    main()
